<?php
/**
 * 公共模型
 * Created by PhpStorm.
 * User: 武 斌
 * Date: 2016/12/14
 * Time: 16:21
 */

namespace Common\Model;


use Think\Model;

class BaseModel extends Model
{
	public function store($data)
	{
		if($this->create($data)){
			//验证成功
//			var_dump($this->pk);die;
			$action = isset($data[$this->pk]) ? 'save' : 'add';
			//echo $action;
			$res = $this->$action($data);
			return ['status'=>'success','message'=>'操作成功','res'=>$res,'data'=>$data];
		}else{
			//验证失败
			return ['status'=>'failed','message'=>$this->getError()];
		}
	}
}